<template>
  <div class="contentBox setScrollbar">
    <div class="setFormMarBtm btnBox">
      <el-form
        :inline="true"
        :model="searchObj"
        class="demo-form-inline"
      >
        <el-form-item label="标题/内容">
          <el-input
            v-model="searchObj.content"
            placeholder="请输入"
          />
        </el-form-item>
        <el-form-item label="参与/发起">
          <el-select
            v-model="searchObj.searchType"
            placeholder="请选择"
            clearable
          >
            <el-option
              label="我参与的"
              value="1"
            />
            <el-option
              label="我发起的"
              value="2"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            @click="onSearch"
          >
            查询
          </el-button>
          <el-button
            type="primary"
            @click="onReset"
          >
            重置
          </el-button>
        </el-form-item>
      </el-form>
      <div>
        <el-button
          type="primary"
          :loading="downloadLoading"
          @click="handleDownload"
        >
          导出
        </el-button>
        <el-button
          type="primary"
          @click="addDiscuss"
        >
          新建讨论
        </el-button>
      </div>
    </div>
    <div class="content">
      <div class="leftTree setScrollbar">
        <el-tree
          :data="treeData"
          :props="defaultProps"
          default-expand-all
          highlight-current
          :expand-on-click-node="false"
          @node-click="handleNodeClick"
        >
          <span
            slot-scope="{ node }"
            class="span-ellipsis"
          >
            <span :title="node.label">{{ node.label }}</span>
          </span>
        </el-tree>
      </div>
      <div class="cntTab setScrollbar">
        <el-table
          v-loading="loading"
          :data="tableData"
          stripe
          style="width: 100%"
          @sort-change="sortChange"
        >
          <el-table-column
            type="index"
            label="序号"
            width="50"
            align="center"
          />
          <el-table-column
            prop="discussTitle"
            label="标题"
            show-overflow-tooltip
          >
            <template slot-scope="scope">
              <span
                class="tabDetail"
                @click="handleDetail(scope.row)"
              >{{
                scope.row.discussTitle
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="userName"
            label="创建人"
            width="120"
          />
          <el-table-column
            prop="deptName"
            label="创建部门"
            width="120"
          />
          <el-table-column
            prop="creatDate"
            label="时间"
            width="160"
            sortable="column"
            align="center"
          />
          <el-table-column
            prop="viewNum"
            sortable="column"
            align="center"
            label="浏览量"
            width="90"
          />
          <el-table-column
            prop="commentNum"
            sortable="column"
            align="center"
            label="评论量"
            width="90"
          />
          <el-table-column
            prop="spotNum"
            sortable="column"
            align="center"
            label="点赞量"
            width="90"
          />
          <el-table-column
            v-if="isMyStart"
            label="操作"
            width="150"
          >
            <template slot-scope="scope">
              <!--<el-button-->
              <!--size="mini"-->
              <!--class="MR18 bg5584FF"-->
              <!--type="primary"-->
              <!--@click="editDiss(scope.row)"-->
              <!--&gt;-->
              <!--编辑-->
              <!--</el-button>-->
              <el-button
                size="mini"
                class="MR18 bg5584FF"
                type="primary"
                @click="deleteDiss(scope.row.discussId)"
              >
                删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页 -->
        <div class="pageBox">
          <el-pagination
            background
            :current-page.sync="currentPage"
            :page-size="10"
            layout="prev, pager, next, jumper"
            :total="total"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </div>
    <el-dialog
      title="新建讨论"
      :visible.sync="addDialogVisible"
      width="60%"
      :close-on-click-modal="false"
      @closed="addHandleClose"
    >
      <el-form
        ref="ruleForm"
        v-loading="addLoading"
        :model="ruleForm"
        :rules="rules"
        label-width="100px"
        class="demo-ruleForm paddLr20 textarea200 select45"
      >
        <el-form-item
          label="标题"
          prop="discussTitle"
          style="width:45%"
        >
          <el-input
            v-model="ruleForm.discussTitle"
            placeholder="请输入"
          />
        </el-form-item>
        <el-form-item
          label="分类"
          prop="cateCode"
          style="width:45%"
        >
          <el-cascader
            v-model="ruleForm.cateCode"
            :options="treeData"
            :props="deftProps"
          />
        </el-form-item>
        <el-form-item label="允许评论">
          <el-radio-group v-model="ruleForm.isComment">
            <el-radio :label="1">
              是
            </el-radio>
            <el-radio :label="0">
              否
            </el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="可见">
          <el-radio-group v-model="ruleForm.visibility">
            <el-radio :label="0">
              所有人
            </el-radio>
            <el-radio :label="1">
              部门可见
            </el-radio>
            <el-radio :label="2">
              角色可见
            </el-radio>
            <el-radio :label="3">
              指定可见
            </el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item
          v-if="ruleForm.visibility == 1"
          label="部门"
          prop="viewDeptId"
          style="width:45%"
        >
          <el-cascader
            v-model="ruleForm.viewDeptId"
            :options="deptData"
            :props="deptDeftProps"
          />
        </el-form-item>
        <el-form-item
          v-if="ruleForm.visibility == 2"
          label="角色"
          prop="viewRoleId"
          style="width:45%"
        >
          <el-select
            v-model="ruleForm.viewRoleId"
            multiple
            value-key="id"
            placeholder="请选择"
          >
            <el-option
              v-for="item in roleData"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          v-if="ruleForm.visibility == 3"
          label="可见人"
          prop="viewUserId"
          style="width:45%"
        >
          <el-select
            v-model="ruleForm.viewUserId"
            multiple
            filterable
            placeholder="请选择"
          >
            <el-option
              v-for="item in userList"
              :key="item.userId"
              :label="item.name"
              :value="item.userId"
            />
          </el-select>
        </el-form-item>
        <!-- action="/system/upload" -->
        <el-form-item
          label="附件："
          style="width:45%"
        >
          <el-upload
            class="upload-demo"
            action="/api/system/upload"
            :on-success="handleSuccess"
            :on-error="handleError"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            :before-upload="beforeAvatarUpload"
            :limit="3"
            :on-exceed="handleExceed"
            :file-list="fileList"
            multiple
          >
            <el-button
              size="small"
              type="primary"
            >
              <i class="el-icon-upload" />上传附件
            </el-button>
            <div
              slot="tip"
              class="el-upload__tip"
            >
              上传单个文件不超过50MB
            </div>
          </el-upload>
        </el-form-item>
        <el-form-item
          label="讨论内容"
          prop="discussContent"
        >
          <el-input
            v-model="ruleForm.discussContent"
            type="textarea"
          />
        </el-form-item>
        <div class="formBtnBox">
          <el-button
            type="primary"
            @click="submitForm('ruleForm')"
          >
            提交
          </el-button>
          <el-button @click="addDialogVisible = false">
            取消
          </el-button>
        </div>
      </el-form>
    </el-dialog>
    <el-dialog
      title="修改讨论"
      :visible.sync="editDialogVisible"
      width="60%"
      :close-on-click-modal="false"
      @closed="addHandleClose"
    >
      <el-form
        ref="ruleForm"
        v-loading="addLoading"
        :model="ruleForm"
        :rules="rules"
        label-width="100px"
        class="demo-ruleForm paddLr20 textarea200 select45"
      >
        <el-form-item
          label="标题"
          prop="discussTitle"
          style="width:45%"
        >
          <el-input
            v-model="ruleForm.discussTitle"
            placeholder="请输入"
          />
        </el-form-item>
        <el-form-item
          label="分类"
          prop="cateCode"
          style="width:45%"
        >
          <el-cascader
            v-model="ruleForm.cateCode"
            :options="treeData"
            :props="deftProps"
          />
        </el-form-item>
        <el-form-item label="允许评论">
          <el-radio-group v-model="ruleForm.isComment">
            <el-radio :label="1">
              是
            </el-radio>
            <el-radio :label="0">
              否
            </el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="可见">
          <el-radio-group v-model="ruleForm.visibility">
            <el-radio :label="0">
              所有人
            </el-radio>
            <el-radio :label="1">
              部门可见
            </el-radio>
            <el-radio :label="2">
              角色可见
            </el-radio>
            <el-radio :label="3">
              指定可见
            </el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item
          v-if="ruleForm.visibility == 1"
          label="部门"
          prop="viewDeptId"
          style="width:45%"
        >
          <el-cascader
            v-model="ruleForm.viewDeptId"
            :options="deptData"
            :props="deptDeftProps"
          />
        </el-form-item>
        <el-form-item
          v-if="ruleForm.visibility == 2"
          label="角色"
          prop="viewRoleId"
          style="width:45%"
        >
          <el-select
            v-model="ruleForm.viewRoleId"
            multiple
            value-key="id"
            placeholder="请选择"
          >
            <el-option
              v-for="item in roleData"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          v-if="ruleForm.visibility == 3"
          label="可见人"
          prop="viewUserId"
          style="width:45%"
        >
          <el-select
            v-model="ruleForm.viewUserId"
            multiple
            filterable
            placeholder="请选择"
          >
            <el-option
              v-for="item in userList"
              :key="item.userId"
              :label="item.name"
              :value="item.userId"
            />
          </el-select>
        </el-form-item>
        <!-- action="/system/upload" -->
        <el-form-item
          label="附件："
          style="width:45%"
        >
          <el-upload
            class="upload-demo"
            action="/api/system/upload"
            :on-success="handleSuccess"
            :on-error="handleError"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            :before-upload="beforeAvatarUpload"
            :limit="3"
            :on-exceed="handleExceed"
            :file-list="fileList"
            multiple
          >
            <el-button
              size="small"
              type="primary"
            >
              <i class="el-icon-upload" />上传附件
            </el-button>
            <div
              slot="tip"
              class="el-upload__tip"
            >
              上传单个文件不超过50MB
            </div>
          </el-upload>
        </el-form-item>
        <el-form-item
          label="讨论内容"
          prop="discussContent"
        >
          <el-input
            v-model="ruleForm.discussContent"
            type="textarea"
          />
        </el-form-item>
        <div class="formBtnBox">
          <el-button
            type="primary"
            @click="submitForm('ruleForm')"
          >
            提交
          </el-button>
          <el-button @click="editDialogVisible = false">
            取消
          </el-button>
        </div>
      </el-form>
    </el-dialog>
    <el-dialog
      title="删除讨论"
      :visible.sync="delDialogVisible"
      width="30%"
      :close-on-click-modal="false"
    >
      <p>确认要删除数据？此操作不可逆</p>
      <div class="formBtnBox">
        <el-button
          type="primary"
          @click="sureDelete"
        >
          确定
        </el-button>
        <el-button @click="delDialogVisible = false">
          取消
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { Message } from 'element-ui';
import { mapGetters } from 'vuex';
import { date } from 'jszip/lib/defaults';
import { clearTreeData } from '@/utils';
export default {
  data() {
    return {
      addDialogVisible: false,
      loading: false,
      addLoading: false,
      downloadLoading: false,
      editDialogVisible: false,
      delDialogVisible: false,
      discussId: '',
      isMyStart: false,
      currentPage: 1,
      total: 0,
      current: 1,
      ruleForm: {
        visibility: 0, // 0所有人可见，1部门可见，2指定人可见
        isComment: 1,
        fileIds: []
      },
      userInfoObj: {
        userId: '',
        deptId: ''
      },
      searchObj: {
        cateCode: '', //树过滤
        searchType: '', //参与发起过滤
        content: '', //内容查询过滤
        prop: '', //升序降序字段
        order: '' //升序降序
      },
      downloadObj: {
        searchType: '' //参与发起过滤
      },
      rules: {
        discussTitle: [
          { required: true, message: '请输入讨论名称', trigger: 'blur' }
        ],
        cateCode: [
          { required: true, message: '请选择分类', trigger: 'change' }
        ],
        isComment: [
          { required: true, message: '请选择是否允许评论', trigger: 'change' }
        ],
        visibility: [
          { required: true, message: '请选择可见', trigger: 'change' }
        ],
        viewDeptId: [
          { required: true, message: '请选择可见部门', trigger: 'blur' }
        ],
        viewRoleId: [
          { required: true, message: '请选择可见角色', trigger: 'blur' }
        ],
        viewUserId: [
          { required: true, message: '请选择指定可见人', trigger: 'blur' }
        ],
        discussContent: [
          { required: true, message: '请输入讨论类容', trigger: 'blur' }
        ]
      },
      fileList: [], //上传文件列表
      treeData: [],
      tableData: [],
      deptData: [],
      roleData: [],
      userList: [],
      options: [
        {
          value: 'zhinan',
          label: '指南',
          children: [
            {
              value: 'shejiyuanze',
              label: '设计原则'
            },
            {
              value: 'daohang',
              label: '导航',
              children: [
                {
                  value: 'cexiangdaohang',
                  label: '侧向导航'
                },
                {
                  value: 'dingbudaohang',
                  label: '顶部导航'
                }
              ]
            }
          ]
        },
        {
          value: 'zujian',
          label: '组件',
          children: [
            {
              value: 'basic',
              label: 'Basic',
              children: [
                {
                  value: 'layout',
                  label: 'Layout 布局'
                },
                {
                  value: 'color',
                  label: 'Color 色彩'
                },
                {
                  value: 'typography',
                  label: 'Typography 字体'
                },
                {
                  value: 'icon',
                  label: 'Icon 图标'
                },
                {
                  value: 'button',
                  label: 'Button 按钮'
                }
              ]
            },
            {
              value: 'form',
              label: 'Form',
              children: [
                {
                  value: 'radio',
                  label: 'Radio 单选框'
                },
                {
                  value: 'checkbox',
                  label: 'Checkbox 多选框'
                },
                {
                  value: 'input',
                  label: 'Input 输入框'
                },
                {
                  value: 'input-number',
                  label: 'InputNumber 计数器'
                },
                {
                  value: 'select',
                  label: 'Select 选择器'
                },
                {
                  value: 'cascader',
                  label: 'Cascader 级联选择器'
                },
                {
                  value: 'switch',
                  label: 'Switch 开关'
                },
                {
                  value: 'slider',
                  label: 'Slider 滑块'
                },
                {
                  value: 'time-picker',
                  label: 'TimePicker 时间选择器'
                },
                {
                  value: 'date-picker',
                  label: 'DatePicker 日期选择器'
                },
                {
                  value: 'datetime-picker',
                  label: 'DateTimePicker 日期时间选择器'
                },
                {
                  value: 'upload',
                  label: 'Upload 上传'
                },
                {
                  value: 'rate',
                  label: 'Rate 评分'
                },
                {
                  value: 'form',
                  label: 'Form 表单'
                }
              ]
            },
            {
              value: 'data',
              label: 'Data',
              children: [
                {
                  value: 'table',
                  label: 'Table 表格'
                },
                {
                  value: 'tag',
                  label: 'Tag 标签'
                },
                {
                  value: 'progress',
                  label: 'Progress 进度条'
                },
                {
                  value: 'tree',
                  label: 'Tree 树形控件'
                },
                {
                  value: 'pagination',
                  label: 'Pagination 分页'
                },
                {
                  value: 'badge',
                  label: 'Badge 标记'
                }
              ]
            },
            {
              value: 'notice',
              label: 'Notice',
              children: [
                {
                  value: 'alert',
                  label: 'Alert 警告'
                },
                {
                  value: 'loading',
                  label: 'Loading 加载'
                },
                {
                  value: 'message',
                  label: 'Message 消息提示'
                },
                {
                  value: 'message-box',
                  label: 'MessageBox 弹框'
                },
                {
                  value: 'notification',
                  label: 'Notification 通知'
                }
              ]
            },
            {
              value: 'navigation',
              label: 'Navigation',
              children: [
                {
                  value: 'menu',
                  label: 'NavMenu 导航菜单'
                },
                {
                  value: 'tabs',
                  label: 'Tabs 标签页'
                },
                {
                  value: 'breadcrumb',
                  label: 'Breadcrumb 面包屑'
                },
                {
                  value: 'dropdown',
                  label: 'Dropdown 下拉菜单'
                },
                {
                  value: 'steps',
                  label: 'Steps 步骤条'
                }
              ]
            },
            {
              value: 'others',
              label: 'Others',
              children: [
                {
                  value: 'dialog',
                  label: 'Dialog 对话框'
                },
                {
                  value: 'tooltip',
                  label: 'Tooltip 文字提示'
                },
                {
                  value: 'popover',
                  label: 'Popover 弹出框'
                },
                {
                  value: 'card',
                  label: 'Card 卡片'
                },
                {
                  value: 'carousel',
                  label: 'Carousel 走马灯'
                },
                {
                  value: 'collapse',
                  label: 'Collapse 折叠面板'
                }
              ]
            }
          ]
        },
        {
          value: 'ziyuan',
          label: '资源',
          children: [
            {
              value: 'axure',
              label: 'Axure Components'
            },
            {
              value: 'sketch',
              label: 'Sketch Templates'
            },
            {
              value: 'jiaohu',
              label: '组件交互文档'
            }
          ]
        }
      ],
      defaultProps: {
        children: 'childs',
        label: 'classificationName'
      },
      deftProps: {
        children: 'childs',
        expandTrigger: 'hover',
        emitPath: false,
        label: 'classificationName',
        value: 'cateCode',
        checkStrictly: true
      },
      deptDeftProps: {
        children: 'nodes',
        expandTrigger: 'hover',
        emitPath: false,
        label: 'text',
        value: 'deptId',
        multiple: true
        // checkStrictly: true
      }
    };
  },
  watch: {
    $route: {
      handler() {
        if (this.$route.query.current) {
          this.current = this.$route.query.current;
          this.currentPage = Number(this.$route.query.current);
        }
      },
      deep: true,
      immediate: true
    },
    searchObj: {
      handler(newObj) {
        this.downloadObj.searchType = newObj.searchType;
      },
      deep: true
    }
  },
  computed: {
    ...mapGetters(['userId', 'deptId'])
  },
  created() {
    this.$set(this.userInfoObj, 'userId', this.userId);
    this.$set(this.userInfoObj, 'deptId', this.deptId);
    this.getTreeList();
    this.getForumList(this.searchObj, { current: this.current, limit: 10 });
    this.getDeptTree();
    this.getUserList();
    this.getRoleTree();
  },
  methods: {
    getTreeList() {
      this.$axios
        .get('/classification/treeList', {
          params: {
            pid: 0
          }
        })
        .then(res => {
          this.treeData = clearTreeData(res.data);
        })
        .catch(() => {});
    },

    getForumList(searchObj, pageObj) {
      this.loading = true;
      const pms = Object.assign(searchObj, pageObj, this.userInfoObj);
      this.$axios
        .post('/forum/list', pms)
        .then(res => {
          if (searchObj.searchType === '2') {
            this.isMyStart = true;
          } else {
            this.isMyStart = false;
          }
          this.tableData = res.data.records;
          this.total = res.data.total;
          this.loading = false;
        })
        .catch(() => {
          this.loading = false;
        });
    },
    getDeptTree() {
      this.$axios.get('/dept/treeview').then(res => {
        this.deptData = res.data;
      });
    },
    getUserList() {
      this.$axios.get('/forum/userList').then(res => {
        this.userList = res.data;
      });
    },
    getRoleTree() {
      this.$axios.get('/role/listRole').then(res => {
        this.roleData = res.data;
      });
    },
    handleNodeClick(data) {
      console.log(data);
      // 树节点点击方法
      if (data.cateCode == 'forum') {
        this.$set(this.searchObj, 'searchType', '');
      }
      this.$set(this.searchObj, 'cateCode', data.cateCode);
      this.getForumList(this.searchObj, { current: this.current, limit: 10 });
    },
    participate() {
      this.$set(this.searchObj, 'searchType', 1);
      this.getForumList(this.searchObj, { current: this.current, limit: 10 });
    },
    handleDownload() {
      this.downloadLoading = true;
      const pms = Object.assign(this.downloadObj, this.userInfoObj);
      this.$axios
        .post('/forum/list', pms)
        .then(res => {
          const list = res.data;
          import('@/vendor/Export2Excel').then(excel => {
            const tHeader = [
              '时间',
              '标题',
              '创建人',
              '创建部门',
              '浏览量',
              '评论量',
              '点赞量'
            ];
            const filterVal = [
              'creatDate',
              'discussTitle',
              'userName',
              'deptName',
              'viewNum',
              'commentNum',
              'spotNum'
            ];
            // const list = this.dowTableData
            const data = this.formatJson(filterVal, list);
            excel.export_json_to_excel({
              header: tHeader,
              data,
              filename: 'discuss',
              autoWidth: this.autoWidth,
              bookType: this.bookType
            });
            this.downloadLoading = false;
          });
        })
        .catch(() => {
          this.downloadLoading = false;
        });
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map(v =>
        filterVal.map(j => {
          if (j === 'timestamp') {
            return parseTime(v[j]);
          } else {
            return v[j];
          }
        })
      );
    },
    addDiscuss() {
      this.addDialogVisible = true;
    },
    radiohandle(data) {},
    submitForm(formName) {
      // 表单提交
      this.$refs[formName].validate(valid => {
        if (valid) {
          switch (this.ruleForm.visibility) {
          case 0:
            if (this.ruleForm.viewDeptId) {
              this.ruleForm.viewDeptId = '';
            }
            if (this.ruleForm.viewRoleId) {
              this.ruleForm.viewRoleId = [];
            }
            if (this.ruleForm.viewUserId) {
              this.ruleForm.viewUserId = '';
            }
            break;
          case 1:
            if (this.ruleForm.viewRoleId) {
              this.ruleForm.viewRoleId = [];
            }
            if (this.ruleForm.viewUserId) {
              this.ruleForm.viewUserId = '';
            }
            break;
          case 2:
            if (this.ruleForm.viewDeptId) {
              this.ruleForm.viewDeptId = '';
            }
            if (this.ruleForm.viewUserId) {
              this.ruleForm.viewUserId = '';
            }
            break;
          case 3:
            if (this.ruleForm.viewDeptId) {
              this.ruleForm.viewDeptId = '';
            }
            if (this.ruleForm.viewRoleId) {
              this.ruleForm.viewRoleId = [];
            }
          }
          this.addLoading = true;
          console.log(this.ruleForm);
          this.$axios
            .post('forum/add', this.ruleForm)
            .then(res => {
              Message({
                message: '创建成功',
                type: 'success',
                duration: 5 * 1000
              });
              this.getForumList(this.searchObj, {
                current: this.current,
                limit: 10
              });
              this.addDialogVisible = false;
              this.addLoading = false;
            })
            .catch(() => {
              this.addLoading = false;
            });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    handleDetail(row) {
      this.$router.push({
        name: 'Discussdetail',
        query: { id: row.discussId, current: this.current }
      });
    },
    sortChange({ column, prop, order }) {
      console.log(column, prop, order);
      if (order == 'descending') {
        this.$set(this.searchObj, 'order', 'desc');
      } else {
        this.$set(this.searchObj, 'order', 'asc');
      }
      this.$set(this.searchObj, 'prop', prop);
      this.getForumList(this.searchObj, { current: this.current, limit: 10 });
    },
    handleCurrentChange(val) {
      // 分页跳转
      this.current = val;
      this.getForumList(this.searchObj, { current: val, limit: 10 });
    },
    addHandleClose() {
      this.$refs.ruleForm.resetFields();
      this.ruleForm = {
        visibility: 0, // 0所有人可见，1部门可见，2指定人可见
        isComment: 1
      };
    },
    onSearch() {
      this.getForumList(this.searchObj, { current: this.current, limit: 10 });
      console.log(this.downloadObj);
    },
    onReset() {
      this.searchObj = {
        cateCode: '', //树过滤
        searchType: '', //参与发起过滤
        content: '', //内容查询过滤
        prop: '', //升序降序字段
        order: '' //升序降序
      };
      this.getForumList(this.searchObj, { current: 1, limit: 10 });
      console.log(this.downloadObj);
    },
    beforeAvatarUpload(file) {
      const isLt2M = file.size / 1024 / 1024 < 50;
      if (!isLt2M) {
        this.$message({
          message: '上传文件大小不能超过 50MB!',
          type: 'warning'
        });
      }
      return isLt2M;
    },
    handleSuccess(response, file, fileList) {
      //上传成功
      Message.success('上传成功');
      console.log(response, file, fileList);
      this.ruleForm.fileIds.push(response.data.fileId);
    },
    handleError(err, file, fileList) {
      //上传失败
      console.log(err, file, fileList);
      Message.error('上传失败');
    },
    handleRemove(file, fileList) {
      // 文件列表移除
      console.log(file, fileList);
      this.ruleForm.fileIds = this.ruleForm.fileIds.filter(item => {
        return item != file.response.data.fileId;
      });
    },
    handlePreview(file) {
      // 点击文件列表中已上传的文件时的钩子
      console.log(file);
    },
    handleExceed(files, fileList) {
      // 文件超出个数限制时的钩子
      console.log(files);
      console.log(fileList);
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${
          files.length
        } 个文件，共选择了 ${files.length + fileList.length} 个文件`
      );
    },
    beforeRemove(file) {
      // 删除文件之前的钩子
      // return this.$confirm(`确定移除 ${file.name}？`).then(() => {
      //   // console.log(file)
      //   // this.$axios.get(`/file/delete/${file.response.data}`)
      // });
    },
    editDiss(row) {
      this.editDialogVisible = true;
      this.ruleForm.discussTitle = row.discussTitle;
      this.ruleForm.cateCode = row.cateCode;
      this.ruleForm.discussContent = row.discussContent;
    },
    deleteDiss(id) {
      this.discussId = id;
      this.delDialogVisible = true;
    },
    sureDelete() {
      const deleteParams = {
        sys_discuss: {
          '@where': {
            'discuss_id@eq': this.discussId
          }
        },
        sys_classification_relation: {
          '@where': {
            'event_id@eq': this.discussId
          }
        },
        dept_discussrealtion: {
          '@where': {
            'discuss_id@eq': this.discussId
          }
        },
        discuss_comment: {
          '@where': {
            'discuss_id@eq': this.discussId
          }
        },
        discuss_spotrelation: {
          '@where': {
            'discuss_id@eq': this.discussId
          }
        },
        discuss_view_relation: {
          '@where': {
            'discuss_id@eq': this.discussId
          }
        },
        file_discussrelation: {
          '@where': {
            'discuss_id@eq': this.discussId
          }
        },
        role_discussrelation: {
          '@where': {
            'discuss_id@eq': this.discussId
          }
        }
      };

      this.COM.jsonsqlForDelete(deleteParams).then(() => {
        this.delDialogVisible = false;
        Message({
          message: '删除成功',
          type: 'success',
          duration: 5 * 1000
        });
        this.getForumList(this.searchObj, {
          current: this.current,
          limit: 10
        });
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.select45 {
  .el-cascader {
    width: 100%;
  }
  .el-select {
    width: 100%;
  }
  .el-upload__tip {
    font-size: 10px;
    font-style: oblique;
    transform: scale(0.8);
    margin-left: -40px;
  }
}
.setFormMarBtm {
  display: flex;
  justify-content: space-between;
  .el-form-item {
    margin-bottom: 0;
  }
}
</style>
